package java8.timeutil;

import java.time.*;

/**
 * @author Cheng Jun
 * @version 1.0
 * Description:
 * @date 2019/8/11 20:37
 */
public class ZonedDateTimeStudy {
    public static void main(String[] args) {
        //包含时区的完整的日期时间(偏移量是以UTC/格林威治时间为基准):2019-08-14T16:12:40.176+08:00[Asia/Shanghai]
        ZonedDateTime zonedDateTime = ZonedDateTime.now();
        zonedDateTime.toEpochSecond();
        //Asia/Shanghai
        ZoneId zoneId = zonedDateTime.getZone();
        //+08:00
        ZoneOffset zoneOffset = zonedDateTime.getOffset();
        // 2019-08-14T16:12:40.176
        LocalDateTime localDateTime = zonedDateTime.toLocalDateTime();
        //2019-08-14T16:12:40.176+08:00[Asia/Shanghai]
        ZonedDateTime newZonedDateTime = ZonedDateTime.of(localDateTime, zoneId);
        //2019-08-14T16:12:40.176+08:00
        OffsetDateTime offsetDateTime = zonedDateTime.toOffsetDateTime();

        // zonedDateTime
        System.out.println(zonedDateTime);
        System.out.println(zoneId);
        System.out.println(zoneOffset);
        System.out.println(localDateTime);
        System.out.println(newZonedDateTime);
        System.out.println(offsetDateTime);
    }
}
